package eteam.aps.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * Swagger文档配置类
 */
@Configuration
@EnableKnife4j
@EnableSwagger2WebMvc
public class Knife4jConfig {
	
    @Bean(value = "essentialDataApi2")
    public Docket essentialDataApi2() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("系统服务")
                        .description("# 系统服务 - Api接口文档")
                        .termsOfServiceUrl("http://localhost:9007/")
                        .contact(new Contact("xx", null, "xx@qq.com"))
                        .version("1.0-SNAPSHOT")
                        .build())
                //分组名称
                .groupName("EssentialDataService")
                .select()
//                .apis(RequestHandlerSelectors.basePackage("eteam.aps.controller"))
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                //.paths(Predicates.not(PathSelectors.regex("/error.*")))//错误路径不监控
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

 
}
